﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script type="text/javascript">

        var value = "aaa";

        function Test(e) {
            //alert(value);
            //this.value = "bbb";
            // 原始事件注册
            //alert(this.value);
            var srcEle;
            if (window.event) {
                srcEle = window.event.srcElement;
            }
            else {
                srcEle = e.target;
            }
            alert(srcEle.value);
        }

        window.onload = function () {
            //document.getElementById("txt").onclick = Test;

            if (window.attachEvent) {//IE 8及以前
                document.getElementById("txt").attachEvent("onclick", Test);
            }
            else {//w3c 火狐
                document.getElementById("txt").addEventListener("click", Test, false);
            }
        }
        
        
    </script>
</head>
<body>
    <input id="txt" type="text"  />
</body>
</html>
